class Server {
    ServerConnection listenConnection = new ServerConnection(8189, 0);
    
    public static void main(String args[]) {
        Server server = new Server();
        server.run();
    }
    
    private void run() {
        //listenConnection.waitForConnection();
        
    }
    
}


/*import java.io.*;
import java.net.*;
import java.lang.*;
import java.util.ArrayList;

class Server {
    // Server connection to listen for new clients, once a client has connected on this port
    // the server will allocate the client another port to connect to.
    private ServerConnection ConnectionServer = null;
    
    // Port to listen for new connections on, 8189 is not used by any services
    private int PortNumber = 8189;
    
    // Event logger
    private Logger log = new Logger("logs/server_" + PortNumber + ".log");
    
    // List of all client connections with the server
    private ArrayList<ServerConnection> ClientConnections = new ArrayList<ServerConnection>();
    
    // Central Data object to get messages from other connections, also used to place
    // Packs for communication with other connections
    private DataHub CentralDataHub = new DataHub();
    
    // Response time is the amount of time (in milliseconds) which the server will sleep for after each run() loop
    private int ResponseTime = 200;

    public Server() {
        this.PortNumber = 8189;
    }

    public Server(int port) {
        this.PortNumber = port;
    }

    public static void main(String args[]) {
        Server s = new Server();
        s.run();
    }

    public void run() {
        int ErrorSleepTime = 3000;      // In MilliSeconds
        boolean quitServer = false;
        
        log.setVerbose(true);
        log.log("Starting Server...");
        this.ConnectionServer = new ServerConnection(this.PortNumber, 0, this.CentralDataHub);

        // Start the server
        if(!ConnectionServer.initServerConnection()) {
            log.log("Error - Could not start listening server connection.");
            return;
        }

        while(quitServer == false) {
            log.log("Checking client connections.");
            checkClientConnections();
            
            log.log("Listening on port " + PortNumber + " waiting for a client...");
            if(ConnectionServer.WaitForConnection()) {
                log.log("Client requesting connection, attempting to connect...");
                if(ConnectionServer.initConnection()) {
                    log.log("Connection established with client, starting port negotiation");
                    
                    if(negotiatePort() != -1) {
                        log.log("Closing connection - Finished port negotiation.");
                        ConnectionServer.closeConnection("Finished port negotiation. Connect to new port.", true);
                    } else {
                        log.log("Closing connection - Failed port negotiation.");
                        ConnectionServer.closeConnection("Failed port negotiation.", false);
                    }
                    
                } else {
                    log.log("Error - Could not establish connection with client. Attempting closeConnection()...");
                    ConnectionServer.closeConnection("Error - Couldn't initialise connection");
                }
            } else {
                log.log("Error waiting for connection, retrying in " + ErrorSleepTime + "ms");
                if(!wait(ErrorSleepTime)) {
                    log.log("Fatal Error - Could not wait for connection or sleep, exiting...");
                    quitServer = true;
                }
            }
            
            //wait(ResponseTime);
        }

        ConnectionServer.closeServerConnection();
    }

    private void checkClientConnections() {
        int i = 0;
        while(i < ClientConnections.size()) {
            ServerConnection tmp = ClientConnections.get(i);
            if(tmp.isAlive()) {
                i++;
            } else {
                log.log("Dropped inactive connection connection on port " + tmp.getPort());
                ClientConnections.remove(i);
            }
        }
    }

    private int negotiatePort() {
        int sendAttempts = 3;
        int i;
        int prt = -1;
        ServerConnection sc = new ServerConnection(0, 30000, this.CentralDataHub);
        sc.start();
        while( (sc.getPort() == 0) && sc.isAlive() ) {
            wait(100);
        }

        if(sc.getPort() == 0) {
            return -1;
        }
        
        prt = sc.getPort();
        
        // Tell client new port
        for(i = 0; i < sendAttempts; i++) {
            if( ConnectionServer.sendData( new Pack(1, Integer.toString(prt), ConnectionServer.serverIP(), ConnectionServer.clientIP()) ) ) {
                log.log("New port number sent to client. New port is " + prt);
                break;
            } else {
                if(i == (sendAttempts - 1)) {
                    log.log("Error - Failed to send new port data to client after " + sendAttempts + " trys giving up");
                } else {
                    log.log("Error - Could not send new port information to client, trying again...");
                }
            }
        }
        
        ClientConnections.add(sc);
        return sc.getPort();
    }

    private boolean wait(int time) {
        try {
            Thread.sleep(time);                 // Wait for a time (ms)
        } catch(InterruptedException e) {
            log.log(e);
            return false;
        }
        return true;
    }
}*/
